package LeetCode.leetcode104;

public class Review2 {
    public int maxDepth(TreeNode root) {
        return reverseMaxDepth(root,0);
    }
    public int reverseMaxDepth(TreeNode root, int maxDepth) {
        if (root == null) return maxDepth;
        int leftMax = reverseMaxDepth(root.left,maxDepth);
        int rightMax = reverseMaxDepth(root.right,maxDepth);
        return Math.max(leftMax,rightMax) + 1;
    }
}
